#include <iostream>
using namespace std;
#include <vector>

const int MAX_VAL = INT32_MAX;

int process(vector<int>& arr , int index , int rest)
{
  if (rest < 0)
  {
    return MAX_VAL;
  }

  if (index == static_cast<int>(arr.size()))
  {
    return rest == 0 ? 0 : MAX_VAL;
  }


  int ways = MAX_VAL;
  for (int fix = 0; fix * arr[index] <= rest; fix++)
  {
    int Next =  process(arr , index + 1 , rest - fix*arr[index]);

    if(Next != MAX_VAL)
    {
      ways = min(ways , Next + fix);
    }
  }
  return ways;
}  

int dp_process(vector<int>& arr ,  int aim)
{
  int N = static_cast<int>(arr.size()) ; // N = arr.size() 
  vector<vector<int>> dp(N + 1 , vector<int>(aim + 1 , MAX_VAL));

  // base case 
  // 1. rest < 0 ?  -1 
  // 
  dp[N][0] = 0;

  for (int index = N -1 ; index >= 0 ; index--)
  {
    for(int rest = 0; rest <= aim; rest++)
    {
        int ways = MAX_VAL;
        for (int fix = 0; fix * arr[index] <= rest; fix++)
        {
          int Next =  dp[index + 1][rest - fix*arr[index]];
      
          if(Next != MAX_VAL)
          {
            ways = min(ways , Next + fix);
          }
        }
        dp[index][rest] = ways;
    }
  }

  return dp[0][aim];
}

int main()
{

  return 0;
}
